<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>config</title>
    <script src="../lib/angularjs/angular.min.js"></script>
</head>

<body>
<div ng-app="myApp">
    <div ng-controller="CartController">
        <h2>name:{{name}}</h2>
        <h3>age:{{b_age}}</h3>
        <h2>user:{{b_user}}</h2>
    </div>
</div>
<script type="text/javascript">
    var app = angular.module("myApp", []);
    app.config(function(myFirstProvider){
        myFirstProvider.name="zhangsan";
    });
    app.provider("myFirst",function(){
        this.$get = function(){
            var that = this;
            var service = {};
            service.console=function(){
                return that.name;
            }
            service.age=123;
            return service;
        }
    });
    app.provider("user",function(){
        this.$get = function(){
            var that = this;
            var u = {
                username:'admin',
                password:'admin'
            };
            return u;
        }
    });
    app.controller("CartController",["myFirst","$scope","user",function(a,b,c){
        console.log(a.console());
        b.name = "lisi";
        b.b_age=a.age;
        b.b_user=c;
    }]);
</script>
</body>

</html>